programming4us
           
 
 
Applications Server

Microsoft Dynamics AX 2009 : Creating modal forms & Changing common form appearance

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
8/17/2011 11:43:16 AM

Creating modal forms

During my trainings and working with Dynamics AX users, I noticed that people who are not familiar with computers and software tend to get lost among open application windows. The same could be applied to Dynamics AX. I experienced many times when a user opened one form, clicked some button to open another one, and then went back to the first one without closing the second one. Sometimes this happens intentionally, sometimes— not, but the result is that the second form is hidden behind the first one and the user starts wondering why it is not possible to close or edit the first form.

Such issues could be easily solved by making the child form a modal window. In other words, the second form always stays on top of the first one until closed. In this recipe, we will do exactly that. As an example, we will make the Create sales order form a modal window.

How to do it...

  1. 1. Open the SalesCreateOrder form in AOT, and set its Design property:

    Property Value
    WindowType Popup

  1. 2. To test, open Accounts receivable | Sales Order Details, and start creating a new order. Notice that now the sales order creation form always stays on top of the Sales order form:

How it works...

Dynamics AX form design has a WindowType property, which is set to Standard by default. In order to make a form behave as a modal window, we have to change it to Popup. Such forms will always stay on top of the parent form.

There's more...

We already know that some of the Dynamics AX forms are created dynamically using the Dialog class. If we look deeper into the code, we could find that the Dialog class actually creates a runtime Dynamics AX form. That means we can apply the same principle, i.e. change the relevant form's design property. The following code could be added to the Dialog object and would do the job:

dialog.dialogForm().buildDesign().windowType(
FormWindowType::Popup);

We get a reference to the form's design, by first using dialogForm() of the Dialog object to get a reference to the DialogForm object, and then we call buildDesign() on the latter object. Then, we set the design's property by calling its windowType() with an argument FormWindowType::Popup.

Changing common form appearance

In every single multi-company Dynamics AX project, in order to prevent user mistakes, I was asked to add functionality that allows setting the background color of every form per company. By doing that, users clearly see in which company account they are at the moment and can easily work within multiple companies at the same time.

In this recipe, we will modify SysSetupFormRun class to change the background color for every form in Dynamics AX.

How to do it...

  1. 1. Open SysSetupFormRun in AOT, and override its run() with the following code:

    public void run()

    {;
    super();
    this.design().colorScheme(FormColorScheme::RGB);
    this.design().backgroundColor(WinAPI::RGB2int(255,0,0));
    }
  2. 2. To test the results, open any Dynamics AX form, for example, General ledger | Chart of Accounts Details and notice how the background color is changed to red:

How it works...

SysSetupFormRun is the application class that is called by the system every time a user runs a form. The best place to add our custom code is to override the run() method and place it under the super().

We use this.design() to get a reference to the form's design. By calling colorScheme() and backgroundColor(), we set the color scheme to red/green/blue and the color code to red.

We use WinAPI::RGB2int() to transform the human-readable red/green/blue code into the numeric color code.

There's more...

This recipe showed a very basic principle of how to change the common appearance of all forms with few lines of code. You noticed that the color in this recipe does not fill all areas of the form, which does not make the form look nice. An alternative to this could be to dynamically add a colored rectangle or something similar to the top of the form. The possibilities are endless here. New controls like input fields, buttons, menu items, and others could also be added to all forms dynamically using this class. But do not overdo as it may impact system performance.

For example, this recipe could be combined with one of the later recipes, Picking a color from Chapter 4, Building Lookups. In this recipe, one color could be set per each Dynamics AX company in the Company information form, and this value could be used in the run() of the SysSetupFormRun class. This would ensure that all forms are colored differently for each Dynamics AX company to make sure users do not get lost among forms when working in multi-company environments.

Other -----------------
- Exchange Server 2010 : Performing Tracking and Logging Activities in an Organization (part 2) - Using Protocol Logging & Using Connectivity Logging
- Exchange Server 2010 : Performing Tracking and Logging Activities in an Organization (part 1) - Using Message Tracking
- Exchange Server 2010 Maintenance, Monitoring, and Queuing : Understanding Troubleshooting Basics
- Extending Microsoft Dynamics CRM 4.0 : Examples
- Extending Microsoft Dynamics CRM 4.0 : IFrames
- BizTalk 2009 : Using XML Namespaces (part 3) - Using System Property Schemas
- BizTalk 2009 : Using XML Namespaces (part 2) - Using Port Filters and Content-Based Routing
- BizTalk 2009 : Using XML Namespaces (part 1) - Understanding Property Promotions
- BizTalk 2009 : Understanding the Message Bus
- Active Directory Domain Services 2008 : Determine Global Catalog Servers
- BizTalk Server 2006 Operations : Disaster Recovery
- Configuring and Using Active Directory Rights Management Services
- Microsoft Dynamics GP 2010 : Installing the Dynamics GP 2010 application
- Microsoft Dynamics GP 2010 : Installing Microsoft SQL Server for Dynamics GP
- Starting a New BizTalk 2009 Project : BizTalk Naming Conventions
- Starting a New BizTalk 2009 Project : BizTalk Assembly Naming and Versioning
- Microsoft Dynamics AX 2009 : Working with Forms - Adding form splitters
- Microsoft Dynamics AX 2009 : Working with Forms - Building dynamic form
- Starting a New BizTalk 2009 Project : Creating a Build-and-Integration Environment (part 2) - Using Test-Driven Development & Creating a BizTalk Installation Package
- Starting a New BizTalk 2009 Project : Creating a Build-and-Integration Environment (part 1) - Five-Step Build Process
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us